package org.jeecg.modules.meter.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.jeecg.entity.basedata.BaseCustomer;
import org.jeecg.entity.basedata.BaseProject;
import org.jeecg.entity.basedata.BaseTenant;
import org.jeecg.entity.charge.ChargeFeeRule;
import org.jeecg.entity.charge.ChargeFeeitem;
import org.jeecg.entity.charge.ChargeStandard;
import org.jeecg.entity.meter.MeterHandRead;
import org.jeecg.vo.basedata.BaseRoomMeterVo;

import java.util.List;


/**
 * @Description: 手抄表
 * @Author: jeecg-boot
 * @Date:   2021-01-17
 * @Version: V1.0
 */
public interface MeterHandReadMapper extends BaseMapper<MeterHandRead> {

    @Select("select * from charge_feeitem where   del_flag ='0' ")
    List<ChargeFeeitem> queryFeeList();

    List<MeterHandRead> findPage(Page<MeterHandRead> page, @Param("room") BaseRoomMeterVo room);
    @Select("select id,name from base_project where depart_id =#{parentId} and del_flag= '0'")
    List<BaseProject> queryProjectList(@Param("parentId") String parentId);

    ChargeFeeRule queryChargeRule(@Param("feeId") String feeId, @Param("roomId") String roomId);

    MeterHandRead queryChargeLastRead(@Param("feeId") String feeId,  @Param("roomId") String roomId);
    @Select("select * from base_customer  where  room_id = #{roomId} and del_flag ='0'")
    BaseCustomer queryCustomerInfo(@Param("roomId") String roomId);

    BaseTenant queryTenantInfo(@Param("roomId") String roomId);



    List<ChargeFeeitem> queryFeeItemByCode(@Param("code") String code,@Param("feeName")String feeName);
    @Select("select * from charge_feeitem where fee_code =#{feeCode} and fee_name = #{codeName} and del_flag ='0'")
    ChargeFeeitem queryChargeFeeItemByCodeAndName(@Param("codeName") String feeCodeName, @Param("feeCode") String feeCode);
    @Update("update meter_hand_read set bills_status= '1' where id = #{id}")
    void updateBillsStatus(@Param("id") String id);

    List<MeterHandRead> handHistoryRead(@Param("id") String id,@Param("feeId") String feeId);

    List<MeterHandRead> queryMeterHandRead(@Param("roomId") String id);

    List<MeterHandRead> allRead(Page<MeterHandRead> page,@Param("room") BaseRoomMeterVo baseRoomMeterVo);

    List<MeterHandRead> findMeterHandRead(@Param("idList")List<String> idList);

    Integer updateBatch(@Param("idList") List<String> idList);

    Integer rollBackBillsStatus(@Param("id") String handId);

    String getLastRead(@Param("bean") MeterHandRead meterHandRead);

    List<MeterHandRead> queryAllRoomHandList(Page<MeterHandRead> page, @Param("roomId") String roomId);
}
